<script>
/*
* print err info of the organization info updates
*/
function updateOrgErrInfo(data)
{
	var element=document.getElementById('organization_name');
	element.innerHTML=data;
}
</script>

<?php $org_form = $this->beginWidget('CActiveForm', array(
		'id'=>'org-form',
		'enableClientValidation'=>true,
	//	'enableAjaxValidation'=>true,
		));
?>

	<div align="right" style="color:#FF0000">
	<label id='organization_name'></label>
	<?php echo $org_form->error($org_model, "organization_name"); ?>
	<?php echo $org_form->error($org_model, "DBA"); ?>
	<?php echo $org_form->error($org_model, "fed_ID"); ?>
	<?php echo $org_form->error($org_model, "address1"); ?>
	<?php echo $org_form->error($org_model, "city"); ?>
	<?php echo $org_form->error($org_model, "state"); ?>
	<?php echo $org_form->error($org_model, "zip"); ?>
	<?php echo $org_form->error($org_model, "phone_number"); ?>
	<?php echo $org_form->error($org_model, "email_address"); ?>
	</div>
	<?php echo $org_form->hiddenField($org_model, 'organization_ID', array('value'=> $row['organization']['organization_ID'])); ?>
  	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  		<tr>
			<th width="84">ORGANIZATION NAME</th>
			<td>
				<div class="rstep2-box">
					<?php echo $org_form->textField($org_model, 'organization_name', array(
																			'value'=> $row['organization']['organization_name'],
																			'ajax'=>array( 
																				'type'=>'POST',
																				'url'=>CController::createUrl('admin/checkOrgValid'),
																				'success'=>'updateOrgErrInfo',
																			),
																			'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)'
																		)); ?>
				</div>
			</td>
		</tr>
		<tr>
			<th>DBA(OPTIONAL)</th>
			<td>
			<div class="rstep2-box">
				<?php 
					if ($row['organization']['DBA'] == 'NULL')
						$row['organization']['DBA'] = '';
					echo $org_form->textField($org_model, 'DBA', array('value'=> $row['organization']['DBA'], 'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)')); 
				?>
			</div>
			</td>
		</tr>
		<tr>
			<th>FED ID#</th>
			<td>
			<div class="rstep2-box">
				<?php echo $org_form->textField($org_model, 'fed_ID', array('value'=>$row['organization']['fed_ID'], 'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)')); ?>
			</div>
			</td>
		</tr>
		<tr>
    		<th>BILLING ADDRESS</th>
    		<td>
    		<div class="rstep1-box1">
    			<?php echo $org_form->textField($org_model, 'address1', array('value'=>$row['organization']['address1'], 'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)')); ?>
    		</div>
    		</td>
    	</tr>
    	<tr>
          	<th>CITY</th>
          	<td width="209">
         	<div class="rstep1-box2">
				<?php echo $org_form->textField($org_model, 'city', array('value'=>$row['organization']['city'], 'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)')); ?>
         	</div>
          	</td>
         </tr>
         <tr>
          	<th>STATE</th>
          	<td>
         	<div class="state"><select name="Organizations[state]">
			  	<?php 
			  	$states = USStates::model()->getAllStates();
			  	foreach ($states as $state) { 
		          	if ($row['organization']['state'] == $state->abbreviation_name)
		          		$selected = "SELECTED";
		          	else
		          		$selected = '';
		          	echo '<option '.$selected.'>'.$state->abbreviation_name.'</option>';
	          	} 
	          	?>
		  	</select></div>
		  	</td>
		 </tr>
		 <tr>
          	<th>ZIP</th>
          	<td>
         	<div class="rstep1-box4">
          		<?php echo $org_form->textField($org_model, 'zip', array('value'=>$row['organization']['zip'], 'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)')); ?>
         	</div>
          	</td>
         </tr>
                  <tr>
          	<th>FIRST NAME</th>
	    	<td>
	    	<div class="rstep1-box5">
	    		<?php echo $org_form->textField($org_model, 'contact_first_name', array('value'=>$row['contact_first_name'], 'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)')); ?>
	    	</div>
	    	</td>
	     </tr>
	     <tr>
          	<th>LAST NAME</th>
	    	<td>
	    	<div class="rstep1-box5">
	    		<?php echo $org_form->textField($org_model, 'contact_last_name', array('value'=>$row['contact_last_name'], 'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)')); ?>
	    	</div>
	    	</td>
	     </tr>
	     <tr>
	    	<th>PHONE #</th>
    		<td>
    		<div class="rstep1-box5">
    			<?php echo $org_form->textField($org_model, 'phone_number', array('value'=>$row['organization']['phone_number'], 'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)')); ?>
    		</div>
    		</td>
    	 </tr>
    	 <tr>
    		<th>EMAIL ADDRESS</th>
    		<td>
    		<div class="rstep1-box5">
				<?php echo $org_form->textField($org_model, 'email_address', array('value'=>$row['organization']['email_address'], 'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)')); ?>
    		</div>
    		</td>
  		 </tr>
  		 <tr>
		    <th>ORGANIZATION TYPE</th>
		    <td><div class="rstep1-box6">
		   		<?php echo $org_form->dropDownList($org_model, 'organization_type_ID', 
									OrganizationTypes::model()->loadOrgTypes(),
									array('style'=>"width:282px;", 'selectedIndex'=>$row['organization']['organization_type_ID'], 'onchange'=>'changeStatus(DOMAIN.ORGANIZATION, STATUS.CHANGED)')
									); ?>
		    </div></td>
		 </tr>
</table>

 <div align='center'>
 	<?php echo CHtml::imageButton(Yii::app()->request->baseUrl.'/images/submit.jpg', array(
										'ajax'=>array(				
											'type'=>'POST',
											'url'=>CController::createUrl('admin/organization'),
											'success'=>'updateStatus',
											'dataType'=>'json',
										),
									)
								); ?>
 </div>
 
<?php $this->endWidget();?>